<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
$strSQL = "select * from `bet_Lotto` where ID = ".(int)$_data["ID"];
if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find Lotto Data Error!!";
	ErrMsgOutputHTML("Error", "", 1);
}

if(PMA_mysql_num_rows($RS) == 0){
	@mysql_close($$_Conn);
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List");
	exit();
}else{
	$objLotto = PMA_mysql_fetch_object($RS);
}
if($objLotto -> LType != 1){
	@mysql_close($$_Conn);
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List");
	exit();
}

//找出 Lotto 的生肖參數，傳回陣列
$arrAnimals = getAnimalsParams($_data["ID"]);
if($arrAnimals === false)ErrMsgOutputHTML("Error", "", 1);

if(!MakeAnimalsParamsFile($objLotto -> ID, $arrAnimals))ErrMsgOutputHTML("Error", "", 1);

$fp = @file($strTemplatePath."Animals.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

$fp = str_replace("{intID}", $objLotto -> ID, $fp);
$strLo = "Lotto_".$_intLang;
$fp = str_replace("{ShowLotto}", $objLotto -> $strLo, $fp);

while(list($k, $v) = each($_strLotto)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

preg_match("/<!-- @ Param Start @ \/\/-->(.+)<!-- @ Param End @ \/\/-->/s", $fp, $arrMatch);
$strParamTmp = $arrMatch[1];

$strCon = "";
for($i = 1; $i <= 6; $i++){
	$ii = $i + 6;

	$strTmp = $strParamTmp;
	$strTmp = str_replace("{ShowAnimals1}", $_arrAnimals[$i], $strTmp);
	$strTmp = str_replace("{ShowAnimals2}", $_arrAnimals[$ii], $strTmp);
	$strTmp = str_replace("{AKey1}", $i, $strTmp);
	$strTmp = str_replace("{AKey2}", $ii, $strTmp);
	$strTmp = str_replace("{AValue1}", $arrAnimals[$i], $strTmp);
	$strTmp = str_replace("{AValue2}", $arrAnimals[$ii], $strTmp);
	$strCon .= $strTmp;
}
$fp = preg_replace("/<!-- @ Param Start @ \/\/-->.+<!-- @ Param End @ \/\/-->/s", $strCon, $fp);

//輸出
WebOutputHTML($fp, 1);
?>